<template>
	<view>
		<ltHead></ltHead>
		<view class="container">
			<view class="index-box" v-for="(item,index) in routerList" :key="index">
				 <view class="router-title" >
					{{item.title}}
				 </view>
				 <view class="router-item">
					 <view v-for="(router,routerIndex) in item.children" :key="routerIndex" @click="routerTo(router)">
						 <ltGrid :name="router.name" :imgSrc="router.imgSrc" />
					 </view>					 
				 </view>
			</view>
			<!-- <view>
				<u-button @click="clean">订阅</u-button>
			</view> -->
		</view>		
	</view>
</template>

<script>
	import ltHead from '../../components/lt-haed.vue'
	import ltGrid from '../../components/lt-gridJump/index.vue';
	import storage from '@/utils/Stroage.js'
	export default{
		data(){
			return{
				routerList:[
					{title:'快捷开单',children:[
						{name:'预约管理',imgSrc:'images/gl.png', router:'/pages/views/bookingManagement/index'},
						{name:'接车问诊',imgSrc:'images/jc.png', router: '/pages/views/carPreFlight/index'},
						// {name:'接车问诊',imgSrc:'images/jc.png'},
						{name:'维修开单',imgSrc:'images/wx.png', router: '/pages/views/repairBill/add'},
						// {name:'维修开单',imgSrc:'images/wx.png'},
					]},
					{title:'我的任务',children:[
						{name:'客户回访',imgSrc:'images/kh.png',router:'/pages/views/clientreview/index'},
						{name:'预约回厂',imgSrc:'images/hc.png'},
						{name:'维修结算',imgSrc:'images/js.png'}
					]},
					{title:'我的看板',children:[
						{name:'预约看板',imgSrc:'images/yykb.png'},
						{name:'客户看板',imgSrc:'images/kb.png',router:'/pages/views/cusList/index'},
						{name:'维修看板',imgSrc:'images/wx.png',router:'/pages/views/repairBill/index'}
						// {name:'维修看板',imgSrc:'images/wx.png'}
					]}
				]
			}
		},
		components:{
			ltHead,
			ltGrid
		},
		methods:{
			routerTo(item){
				if(!item.router){
					uni.showToast({
						title:'开发中，敬请期待!',
						icon:'none',
						duration:3000
					})
				}
				uni.navigateTo({
				    url: item.router
				});
			},
			clean(){
				let accessToken = storage.get(access_token)
				// uni.request({
				// 	url:`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxa472f45fe86816fa&secret=3e865bde1e9c48785781e4186724b01c`,
				// 	success: (res) => {
				// 	        console.log(res.data);
				// 	        storage.set('access_token',res.data.access_token)
				// 	  }
				// })
				// uni.request({
				// 	url:`https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=${accessToken}`
				// 	method:"POST",
				// 	data:{}
				// })
				return 
				wx.requestSubscribeMessage({
					tmplIds: ['upCJH03-GFQxHUKnQAXikm2pPm1QK8fwne7IWFyLsSk'],
					success: (res)=> {
						console.log(res)
					},
					fail: (res)=> { console.info(res) },
				})
			}
		}
	}
</script>
	
<style lang="scss" scoped>
	.index-box{
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		padding: 0;
		margin-top:  42upx;
		.router-title{
			font-size: 30upx;
			font-weight: bold;
			padding-left: 12upx;
		}
		.router-item{
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			margin-top: 20upx;
		}
	}
</style>
